<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *留言记录
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$tabs=array(
	array('op'=>'list','title'=>'申请列表'),
);
if($_RQ['op']=='list'){
	$type=intval($_RQ['type']);
	$params=array('merchid'=>$merchid,'uniacid'=>$_SESSION['uniacid']);
	if(isset($_RQ['status'])){
		$params['status']=intval($_RQ['status']);
		$return['params']['status']=intval($_RQ['status']);
	}
	if($_SESSION['os']!='windows'){
		$params['status']=intval($_RQ['status']);
		$return['params']['status']=intval($_RQ['status']);
	}
	if(!empty($_RQ['itemid'])){
		$params['itemid']=intval($_RQ['itemid']);
		$return['params']['itemid']=intval($_RQ['itemid']);
	}
	if(!empty($_RQ['jobtitle'])){
		$jobids=pdo_getall('jy_aihire_job',array('uniacid'=>$_SESSION['uniacid'],'title like %'=>$_RQ['jobtitle'].'%'),'id','id');
		$jobids=$jobids?:-1;
		$params['itemid']=$jobids;
		$return['params']['jobtitle']=$_RQ['jobtitle'];
	}
	if(!empty($_RQ['username'])){
		$memberids=pdo_getall('jy_aihire_member',array('uniacid'=>$_SESSION['uniacid'],'username like %'=>$_RQ['username'].'%'),'id','id');
		$memberids=$memberids?:-1;
		$params['memberid']=$memberids;
		$return['params']['username']=$_RQ['username'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_aihire_job_log',$params,array($pindex,$psize),$total,$fields,'','id desc');
	foreach($list as &$item){
		$item['member']=$this->model('member')->member_show($item['memberid']);
		$item['jobtitle']=pdo_getcolumn('jy_aihire_job',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['jobid']),'title');
		$job=pdo_get('jy_aihire_job',array('id'=>$item['jobid'],'uniacid'=>$_SESSION['uniacid']));
		$item['pay']=$job['pay'];
		$item['city']=$job['city'];
		$item['onlinetime']=json_decode($job['onlinetime'],true);
		$item['images']=json_decode($job['images'],true);
		$item['baotypetitle']=$this->job_paytype2[$job['paytype']].'结('.$this->job_baotype[$job['baotype']].'版)';
		$item['statustitle']=$this->joblog_status[$item['status']];
		$item['createtime']=date('Y-m-d H:i:s', $item['createtime']);
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'member','title'=>'用工信息','type'=>'member'),
			array('name'=>'jobtitle','title'=>'工作名称','type'=>'string'),
			array('name'=>'comment','title'=>'申请内容','type'=>'string'),
			array('name'=>'createtime','title'=>'时间','type'=>'string'),
			array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status'),
		),'action'=>array(
			array('title'=>'审核操作','type'=>'modal','op'=>'check','show'=>array('status'=>array(0,1,2))),
		)),
		'search'=>array(
			array('name'=>'jobtitle','width'=>15,'title'=>'工作名称','type'=>'string'),
			array('name'=>'username','width'=>15,'title'=>'申请人姓名','type'=>'string'),
		)
	);
	if($_SESSION['os']=='windows'){
		$return['htmls']=$htmls;
	}
	$return['status']=$this->joblog_status;
	exi($return);
}
if($_RQ['op']=='check'){
	if($_RQ['postdata']){
		$post=get_postdata();
		$status=intval($post['status']);
		if($status==1){
			$this->model('job')->upgong($post,$status);
		}
		if($status==2){
			pdo_update('jy_aihire_job_log',array('status'=>2),array('id'=>$post['joblogid'],'uniacid'=>$_SESSION['uniacid']));
		}
		pdo_update('jy_aihire_job_log',array('status'=>$status),array('merchid'=>$merchid,'uniacid'=>$_SESSION['uniacid'],'id'=>intval($post['id'])));
		exi('处理成功！','','/merch.zhao_log/list/');
	}
	$item=pdo_get('jy_aihire_job_log',array('merchid'=>$merchid,'uniacid'=>$_SESSION['uniacid'],'id'=>intval($_RQ['id'])));
	if(!$item){
		exi('应聘申请不存在！','error');
	}
	$return['item']=$item;
	$return['htmls']=array(
		'type'=>'edit',
		'desc'=>'审核应聘申请',
		'edit'=>array(
			array('name'=>'status','title'=>'审核','type'=>'radio','options'=>'joblog_status'),
		),
	);
	$return['joblog_status']=$this->joblog_status2;
	exi($return);
}
if($_RQ['op']=='del'){
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
	}else{
		$del=array();
	}
	if($_RQ['id']){
		$del[]=$_RQ['id'];
	}
	foreach($del as $id){
		$id=intval($id);
		if($id){
			pdo_delete('jy_aihire_job_log',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
		}
	}
	exi('删除成功！');
}
